package com.factory;

import com.factory.service.Builder;

public class FactoryMain {
    public Builder getbean(String name){
        try {
            //通过反射创建builder对象
            Class clazz=Class.forName(FactoryConfig.config.get(name));
            Object o=clazz.newInstance();
            if (o instanceof Builder)
                return (Builder) o;
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
        return null;
    }
}
